﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AppSocketModel;
using AppSocketService.SendCmd;
using BCGPSCommon;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BCGPSRESTful.Controllers.Page.Command
{
    /// <summary>
    /// 给GSP设备发查询余额命令
    /// </summary>
    [ApiExplorerSettings(GroupName = "DeviceCmd")]
    [Route("api/[controller]")]
    [ApiController]
    public class SimCardYeController : PageBaseController
    {
        ISimCardYEHistoryService simCardYEHistoryService;
        /// <summary>
        /// 
        /// </summary>
        public SimCardYeController(ISimCardYEHistoryService simCardYEHistoryService)
        {
            this.simCardYEHistoryService = simCardYEHistoryService;
        }

        /// <summary>
        /// 给GSP设备发查询余额命令
        /// </summary>
        /// <param name="imei"></param>
        /// <returns></returns>
        [ProducesResponseType(typeof(bool), 200)]
        [HttpGet("[action]")]
        public ActionResult<bool> SetCmdYE(string imei)
        { 
            return simCardYEHistoryService.SetCmdYE(imei);
        }


        /// <summary>
        /// 查询历史记录
        /// </summary>
        /// <param name="imei"></param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="desc">倒序</param>
        /// <param name="index">页码</param>
        /// <param name="size">记录数</param>
        /// <returns></returns>
        [ProducesResponseType(typeof(PageableList<SimCardYEDto>), 200)]
        [HttpGet("[action]")]
        public ActionResult<PageableList<SimCardYEDto>> Query(string imei,DateTime start,DateTime end,bool? desc = false ,int ? index=0,int ?  size=20)
        {
            return simCardYEHistoryService.GetList(imei, start, end,desc.Value,index.Value,size.Value);
        }
    }
}